package cn.com.surker.pages.console;

import cn.com.surker.common.AbstractController;
import cn.com.surker.common.Constant;
import cn.com.surker.enums.ICodeDescEnum;
import cn.com.surker.enums.production.car.OverLimitEnum;
import cn.com.surker.enums.production.indent.ProTypeEnum;
import cn.com.surker.enums.production.indent.RoadTypeEnum;
import cn.com.surker.enums.production.invoice.ShipTypeEnum;
import cn.com.surker.enums.sale.ContractCategoryEnum;
import cn.com.surker.system.entity.SysMenuRoleController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * @Author luotao
 * @create 2024年09月06 09:43
 * @desc
 */
@Slf4j
@Controller
@RequestMapping("/console/production")
public class ProductionController extends AbstractController {

	/**
	 * 任务单页面
	 *
	 * @return
	 */
	@RequestMapping(value = "/indent")
	public ModelAndView indent() {
		//	菜单权限
		SysMenuRoleController menuRole = isControlVerify("/console/production/indent");
		//	基础数据
		List<Map<String, Object>> categoryList = ICodeDescEnum.getEnumDatas(ContractCategoryEnum.class);
		List<Map<String, Object>> roadTypeList = ICodeDescEnum.getEnumDatas(RoadTypeEnum.class);
		List<Map<String, Object>> indentTypeList = ICodeDescEnum.getEnumDatas(ProTypeEnum.class);
		List<Map<String, Object>> overLimitList = ICodeDescEnum.getEnumDatas(OverLimitEnum.class);
		ModelAndView mv = new ModelAndView();
		mv.addObject("categoryList", categoryList);
		mv.addObject("roadTypeList", roadTypeList);
		mv.addObject("indentTypeList", indentTypeList);
		mv.addObject("overLimitList", overLimitList);
		mv.addObject("menuRole", menuRole);
		mv.setViewName("console/production/indent");
		return mv;
	}

	/**
	 * 调度中心页面
	 *
	 * @return
	 */
	@RequestMapping(value = "/dispatch")
	public ModelAndView dispatch() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("console/production/dispatch");
		return mv;
	}

	@Deprecated
	@RequestMapping(value = "/dispatch_old")
	public ModelAndView dispatchOld() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("console/production/dispatch_old");
		return mv;
	}

	/**
	 * 发货单页面
	 *
	 * @return
	 */
	@RequestMapping(value = "/invoice")
	public ModelAndView invoice(Long indentId) {
		ModelAndView mv = new ModelAndView();
		//	菜单权限
		SysMenuRoleController menuRole = isControlVerify("/console/production/invoice");
		//	基础数据
		List<Map<String, Object>> categoryList = ICodeDescEnum.getEnumDatas(ContractCategoryEnum.class);
		List<Map<String, Object>> roadTypeList = ICodeDescEnum.getEnumDatas(RoadTypeEnum.class);
		mv.addObject("categoryList", categoryList);
		mv.addObject("roadTypeList", roadTypeList);
		mv.addObject("initIndentId", indentId);
		mv.addObject("menuRole", menuRole);
		Integer isAdmin = 0;
		if (isAdmin()) {
			isAdmin = 1;
		}
		mv.addObject("isAdmin", isAdmin);
		mv.setViewName("console/production/invoice");
		return mv;
	}

	@RequestMapping(value = "/invoice/detail")
	public ModelAndView invoiceDetail(Long invoiceId) {
		ModelAndView mv = new ModelAndView();
		mv.addObject("invoiceId", invoiceId);
		mv.setViewName("console/production/invoice-detail");
		return mv;
	}

	/**
	 * 退砼处理页面
	 *
	 * @return
	 */
	@RequestMapping(value = "/invoice/back")
	public ModelAndView invoiceBack() {
		ModelAndView mv = new ModelAndView();
		SysMenuRoleController menuRole = isControlVerify("/console/production/invoice");
		mv.addObject("menuRole", menuRole);
		mv.setViewName("console/production/invoice-back");
		return mv;
	}

	/**
	 * 工控机的发货信息页面
	 *
	 * @return
	 */
	@RequestMapping(value = "/control/invoice")
	public ModelAndView controlInvoice() {
		ModelAndView mv = new ModelAndView();
		SysMenuRoleController menuRole = isControlVerify("/console/production/invoice");
		mv.addObject("menuRole", menuRole);
		mv.setViewName("console/production/control-invoice");
		return mv;
	}

	/**
	 * 发货单处理记录
	 *
	 * @return
	 */
	@RequestMapping(value = "/handle/page")
	public ModelAndView handlePage() {
		ModelAndView mv = new ModelAndView();
		SysMenuRoleController menuRole = isControlVerify("/console/production/handle/page");
		List<Map<String, Object>> typeList = ICodeDescEnum.getEnumDatas(ShipTypeEnum.class);
		mv.addObject("typeList", typeList);
		mv.addObject("menuRole", menuRole);
		mv.setViewName("console/production/invoice-handle-record");
		return mv;
	}
}
